/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package demo;

import java.io.IOException;
import java.util.Timer;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author tmp
 */
public class Materazzi {
    private Sprite sprite;
    private SpriteAnimationTask spriteAnimator;
    private SpriteFixoMovement spriteFixoMovement;

    public Materazzi(DemoGameCanvas canvas,Sprite visao, int[][] sequencias, int delay,int[] qtdMoviment, Sprite materazzi) throws IOException {
        GameDesign gameDesign;
        Timer timer;
        timer = canvas.getTimer();
        gameDesign = canvas.getGameDesign();
       
        this.sprite = visao;
        //define the reference in the midle of sprites frame so that transformations work well
        this.sprite.defineReferencePixel(8, 8);
        this.spriteAnimator = new SpriteAnimationTask(this.sprite, true);
        this.spriteAnimator.setMoving(true);
        timer.scheduleAtFixedRate(this.spriteAnimator, 0, delay);
        this.spriteFixoMovement = new SpriteFixoMovement(canvas, sprite, materazzi);
        this.spriteFixoMovement.setSequences(
            sequencias[0], Sprite.TRANS_NONE, 
            sequencias[1], Sprite.TRANS_NONE, 
            sequencias[2], Sprite.TRANS_NONE, 
            sequencias[3], Sprite.TRANS_NONE,qtdMoviment
            );
        (new Thread(spriteFixoMovement)).start();
    }

    
    
    public Sprite getSprite(){
        return this.sprite;
    }

}
